package com.mall.service.homepage.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.commons.common.CommonPage;
import com.mall.model.domain.SmsHomeBrand;
import com.mall.model.domain.SmsHomeNewProduct;
import com.mall.service.homepage.mapper.HomeNewProductMapper;
import com.mall.service.homepage.service.HomeNewProductService;
import org.springframework.stereotype.Service;

@Service
public class HomeNewProductImpl extends ServiceImpl<HomeNewProductMapper,SmsHomeNewProduct> implements HomeNewProductService {
    @Override
    public CommonPage<SmsHomeNewProduct> findByPage(Integer pageNum, Integer pageSize, String productName, Integer recommendStatus) {
        Page<SmsHomeNewProduct> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<SmsHomeNewProduct> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(productName!=null,SmsHomeNewProduct::getProductName,productName);
        queryWrapper.like(recommendStatus!=null,SmsHomeNewProduct::getRecommendStatus,recommendStatus);
        this.page(page,queryWrapper);
        CommonPage <SmsHomeNewProduct> commonPage= CommonPage.getPage(page);

        return commonPage;
    }
}
